package com.example.spring_aop.advice;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

public class MyAspect implements MethodInterceptor {

    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {
        String name = invocation.getMethod().getName();
        before(name);
        Object proceed = invocation.proceed();
        after(name);
        return proceed;
    }

    public void before(String methodName) {
        System.out.println(methodName + "方法调用前");
    }

    public void after(String methodName) {
        System.out.println(methodName + "方法调用后");
    }
}
